package com.acegear.horizon.domain.models.jpa;

import com.acegear.horizon.domain.models.jpa.convert.ContentPartConverter;
import com.fasterxml.jackson.annotation.JsonIgnore;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 * Created by mercury on 2016/12/18.
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
public class ClubInfo {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonIgnore
    private Long id;

    @Column(unique = true)
    private Long clubId;

    @Column(columnDefinition = "TEXT")
    private String info;

    @OneToOne(cascade = CascadeType.ALL)
    private ContactInfo contact;

    @OneToOne(cascade = CascadeType.ALL)
    private Address address;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = ContentPartConverter.class)
    private List<ContentPart> introduction;

    @CreatedDate
    @Column
    private Long createAt;

    @LastModifiedDate
    @Column
    private Long updateAt;

    public ClubInfo() {
    }

    public ClubInfo(Long clubId, String info, ContactInfo contact, Address address, List<ContentPart> introduction) {
        this.clubId = clubId;
        this.info = info;
        this.contact = contact;
        this.address = address;
        this.introduction = introduction;
    }

    public Long getCreateAt() {
        return createAt;
    }

    public Long getUpdateAt() {
        return updateAt;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getClubId() {
        return clubId;
    }

    public void setClubId(Long clubId) {
        this.clubId = clubId;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public ContactInfo getContact() {
        return contact;
    }

    public void setContact(ContactInfo contact) {
        this.contact = contact;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public List<ContentPart> getIntroduction() {
        return introduction;
    }

    public void setIntroduction(List<ContentPart> introduction) {
        this.introduction = introduction;
    }
}
